home *** CD-ROM | disk | FTP | other *** search
- Path: bcarh8ab.bnr.ca!liyu
- From: liyu@bnr.ca (whyme)
- Newsgroups: comp.lang.c++
- Subject: what getline returns? Nobody can explain this!!
- Date: 16 Mar 1996 21:25:28 GMT
- Organization: Bell-Northern Research Canada
- Distribution: na
- Message-ID: <4ifbk8$6nf@bcarh8ab.bnr.ca>
- NNTP-Posting-Host: bcarsfb3.bnr.ca
-
- getline member fuction in ifstream is supposed to return the
- receiving object (that is, ostream&).
-
- However, many books contain the code samples like:
-
- ifstream in("tmp.txt");
- while (in.getline(buffer,sizeof(buffer))) { ... }
-
- This loop quits only if in.getline returns 0 or NUll;
- ^^^^^^^
-
- but an ostream object is neither 0 nor NULL;
- the result is an object, not integer or pointer.
-
- So how can this loop quit?
-
- It works; but no one I know can explain this!!!!
- Thanks for your help.
-